package File;

import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

public class WriterFile2 {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		String str;
		FileWriter fw = null;
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			fw = new FileWriter("data2.txt");
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		System.out.println("Nhap vao chuoi cho den khi nhap 'stop':");
		
		do{
			str = br.readLine();
			if(str.compareTo("stop") == 0)
				break;
			str = str + "\n";
			fw.write(str);
		}while(str.compareTo("stop") != 0);
		fw.close();
	}

}
